﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.SqlTypes;
using System.Xml;
using System.Data.Objects;
using GAE_PI.Models;
using GAE_PI.Exceptions;

namespace GAE_PI.Controllers
{
    public class DetailActiviteController : Controller
    {
        //
        // GET: /DetailActivite/
        public ActionResult DetailActivite(string nomA)
        {
            try
            {
                return View(DBModel.getDBM().getDetailForActivite(nomA,false));
            }
            catch (GAEException ex)
            {
                ex.errorModel.ControllerName = "DetailActivite";
                ex.errorModel.ControllerAction = "DetailActivite";
                return View("Error", ex.errorModel);
            }
        }

        public ActionResult Inscription(string nomA)
        {
            try
            {
                DBModel.getDBM().inscription(nomA);
            }
            catch (GAEException ex)
            {
                ex.errorModel.ControllerName = "DetailActivite";
                ex.errorModel.ControllerAction = "Inscription";
                return View("Error", ex.errorModel);
            }
            return RedirectToAction("DetailActivite", "DetailActivite", new { nomA });
        }

        public ActionResult Desinscription(string nomA)
        {
            try
            {
                DBModel.getDBM().desinscription(nomA);
            }
            catch (GAEException ex)
            {
                ex.errorModel.ControllerName = "Desinscription";
                ex.errorModel.ControllerAction = "Inscription";
                return View("Error", ex.errorModel);
            }
            return RedirectToAction("DetailActivite", "DetailActivite", new { nomA });
        }
    }
}
